package org.example.common.handle;

import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author 李荣
 * @Date 2025/1/20
 * @Description
 */
@Component
public class WebSocketHandle {
    private final SimpMessagingTemplate messagingTemplate;

    public WebSocketHandle(SimpMessagingTemplate messagingTemplate) {
        this.messagingTemplate = messagingTemplate;
    }
    public void sendToTopic(String message) {
        messagingTemplate.convertAndSend("/topic/messages", message);
    }
}
